package com.xingzuo.library_expert.ui;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.xingzuo.base.app.AppActivityKey;
import com.xingzuo.base.ui.mvp.base.ui.BaseMvpActivity;
import com.xingzuo.common.view.calendarview.bean.DateBean;
import com.xingzuo.common.view.calendarview.listener.OnPagerChangeListener;
import com.xingzuo.common.view.calendarview.listener.OnSingleChooseListener;
import com.xingzuo.common.view.calendarview.utils.CalendarUtil;
import com.xingzuo.common.view.calendarview.weiget.CalendarView;
import com.xingzuo.library_expert.R;
import com.xingzuo.library_expert.R2;
import com.xingzuo.library_expert.contract.MyReservationContract;
import com.xingzuo.library_expert.presenter.MyReservationPresenter;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

@Route(path = AppActivityKey.MYRESERVATIONACTIVITY)
public class MyReservationActivity extends BaseMvpActivity<MyReservationPresenter> implements MyReservationContract.View {
    @BindView(R2.id.rv_back)
    ImageView rvBack;
    @BindView(R2.id.calendar)
    CalendarView calendar;
    @BindView(R2.id.tv_date)
    TextView tvDate;
    private int[] cDate = CalendarUtil.getCurrentDate();

    @Override
    public MyReservationPresenter getPresenter() {
        return new MyReservationPresenter();
    }

    @Override
    public int getView() {
        return R.layout.activity_myreservation;
    }

    @Override
    public void initView() {
        calendar
//                .setSpecifyMap(map)
                .setStartEndDate("2016.1", "2028.12")
                .setDisableStartEndDate("2016.10.10", "2028.10.10")
                .setInitDate(cDate[0] + "." + cDate[1])
                .setSingleDate(cDate[0] + "." + cDate[1] + "." + cDate[2])
                .init();
        tvDate.setText(cDate[0] + "年" + cDate[1] + "月" + cDate[2]+"日");
        calendar.setOnSingleChooseListener(new OnSingleChooseListener() {
            @Override
            public void onSingleChoose(View view, DateBean date) {
                int[] solar=date.getSolar();
                tvDate.setText(solar[0] + "年" + solar[1] + "月" + solar[2]+"日");
            }
        });
        calendar.setOnPagerChangeListener(new OnPagerChangeListener() {
            @Override
            public void onPagerChanged(int[] date) {
                tvDate.setText(date[0] + "年" + date[1] + "月" + date[2]+"日");
            }
        });
    }

    @Override
    public void initLinsenterner() {

    }

    @Override
    public void getData() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick(R2.id.rv_back)
    public void onViewClicked() {
        finishActivity();
    }
}